#! -*- coding: utf-8 -*-
import sys
sys.path.insert(0, '..')
import app.models as models  # 可以直接从这里取得各个model对象，比如Mtu, Supplier, Product等
import app.elastic_models as elastic_models

from mongoengine import connect

MONGODB_SETTINGS = {
    'host': '192.168.1.198',
    'port': 27017
}
connect('vtc', **MONGODB_SETTINGS)  # 只要connect之后，就可以用model来创建数据了


def sync_product():
    for product in models.Product.objects:
        # print product.name, product.id
        elastic_models.ProductDoc.sync(product)

if __name__ == '__main__':
    sync_product()
